# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=clipper
pkgver=6.4.2
pkgrel=5
pkgdesc="Polygon, line clipping and offsetting library"
options="!check" # No testsuite
url="https://sourceforge.net/projects/polyclipping/"
arch="all"
license="BSL-1.0"
makedepends="cmake samurai"
subpackages="$pkgname-static $pkgname-dev"
source="https://sourceforge.net/projects/polyclipping/files/clipper_ver$pkgver.zip"
builddir="$srcdir/cpp"

prepare() {
	default_prepare
	sed -i 's|/share/|/lib/|' CMakeLists.txt
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi

	cmake -B build-shared -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=Release \
		$CMAKE_CROSSOPTS

	cmake --build build-shared

	cmake -B build-static -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=OFF \
		-DCMAKE_BUILD_TYPE=Release \
		$CMAKE_CROSSOPTS

	cmake --build build-static
}

package() {
	DESTDIR="$pkgdir" cmake --install build-static
	DESTDIR="$pkgdir" cmake --install build-shared
}

sha512sums="
ffc88818c44a38aa278d5010db6cfd505796f39664919f1e48c7fa9267563f62135868993e88f7246dcd688241d1172878e4a008a390648acb99738452e3e5dd  clipper_ver6.4.2.zip
"
